<!--
 * @Author: early-autumn
 * @Date: 2020-05-15 11:15:41
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-07-10 13:22:26
 -->
<template>
  <div>
    <div class="msgBox">
      <div class="leftBox">
        <el-card class="leftCard">
          <div class="xian"></div>
          <div class="msg">
            <div class="box1">
              <ul class="card__content-list">
                <li class="card__content-item">
                  <span class="card__content-item-label">姓名:</span>
                  <span class="card__content-item-value">
                    {{ patient.name }}
                  </span>
                </li>
                <li class="card__content-item">
                  <span class="card__content-item-label">性别:</span>
                  <span class="card__content-item-value">
                    {{ sexEnum[patient.sex] }}
                  </span>
                </li>
                <li class="card__content-item">
                  <span class="card__content-item-label">年龄:</span>
                  <span class="card__content-item-value">
                    {{ patient.age == 0 ? '/' : patient.age }}
                  </span>
                </li>
              </ul>
              <div class="avatar">
                <avatar-image
                  style="height: 100%; width: 100%"
                  :patient="patient"
                />
              </div>
            </div>
            <div class="box2">
              <ul class="card__content-list">
                <li class="card__content-item">
                  <span class="card__content-item-label">生日:</span>
                  <span class="card__content-item-value">
                    {{ patient.birthday }}
                  </span>
                </li>
                <li class="card__content-item">
                  <span class="card__content-item-label">电话1:</span>
                  <span class="card__content-item-value">
                    {{ patient.phoneNumber }} &nbsp;&nbsp;&nbsp;
                    <el-tag type="danger" size="mini">
                      {{
                        formatterDict(
                          patient.phoneOwnership,
                          'phoneOwnershipOptions'
                        )
                      }} </el-tag
                    >&nbsp;&nbsp;&nbsp;
                    <el-tag
                      v-if="showBtn"
                      type="success"
                      size="mini"
                      style="cursor: pointer"
                      @click="checkPhone()"
                      >查看电话</el-tag
                    >
                  </span>
                </li>
                <li v-if="patient.phoneNumber2" class="card__content-item">
                  <span class="card__content-item-label">电话2:</span>
                  <span class="card__content-item-value">
                    {{ patient.phoneNumber2 }} &nbsp;&nbsp;&nbsp;
                    <el-tag type="danger" size="mini">
                      {{
                        formatterDict(
                          patient.phoneOwnership2,
                          'phoneOwnershipOptions'
                        )
                      }} </el-tag
                    >&nbsp;&nbsp;&nbsp;
                  </span>
                </li>
                <li class="card__content-item">
                  <span class="card__content-item-label">状态:</span>
                  <span class="card__content-item-value">
                    {{ customerStatusEnum[patient.personStatus] }}
                  </span>
                </li>
                <li class="card__content-item">
                  <span class="card__content-item-label">地址:</span>
                  <span class="card__content-item-value">
                    {{
                      `${patient.province} ${patient.city} ${patient.district}`
                    }}
                  </span>
                </li>
              </ul>
            </div>
            <div class="box3">
              <ul class="card__content-list">
                <li class="card__content-item">
                  <span class="card__content-item-label">病历号:</span>
                  <span class="card__content-item-value">
                    {{ patient.caseNumber }}
                  </span>
                </li>
                <li class="card__content-item">
                  <span class="card__content-item-label">黄页编号:</span>
                  <span class="card__content-item-value">
                    {{ patient.yellowCode }}
                  </span>
                </li>
                <!-- <li class="card__content-item">
                  <span class="card__content-item-label">访问病种:</span>
                  <span class="card__content-item-value">
                    {{
                    !patient.visitDisease?'/':patient.visitDisease
                    }}
                  </span>
                </li> -->
              </ul>
            </div>
          </div>
        </el-card>
      </div>
      <div class="rightBox">
        <el-card class="rCard" style="min-height: 110px; padding-top: 20px">
          <div class="xian"></div>
          <div class="rbox1">
            <ul class="card__content-list">
              <li class="card__content-item">
                <span class="card__content-item-label">职业:</span>
                <span class="card__content-item-value">
                  {{
                    professionalEnum[patient.profession]
                      ? professionalEnum[patient.profession]
                      : '/'
                  }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">QQ号:</span>
                <span class="card__content-item-value">
                  {{ patient.qqNumber ? patient.qqNumber : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">微信号:</span>
                <span class="card__content-item-value">
                  {{ patient.wechatNumber ? patient.wechatNumber : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">身份证:</span>
                <span class="card__content-item-value">
                  {{ patient.idCard ? patient.idCard : '/' }}
                </span>
              </li>
            </ul>
            <ul class="card__content-list">
              <li class="card__content-item">
                <span class="card__content-item-label">详细地址:</span>
                <span class="card__content-item-value">
                  {{ patient.addressDetailed }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">婚姻状况:</span>
                <span class="card__content-item-value">
                  {{
                    maritalStatusEnum[patient.maritalStatus]
                      ? maritalStatusEnum[patient.maritalStatus]
                      : '/'
                  }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">有无小孩:</span>
                <span class="card__content-item-value">
                  {{
                    haveChildEnum[patient.haveChild]
                      ? haveChildEnum[patient.haveChild]
                      : '/'
                  }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">正畸编号:</span>
                <span class="card__content-item-value">
                  {{
                    patient.orthodonticsCode ? patient.orthodonticsCode : '/'
                  }}
                </span>
              </li>
            </ul>
          </div>
        </el-card>
        <el-card class="rCard" style="min-height: 160px; margin-top: 20px">
          <div class="xian"></div>
          <div class="rbox2">
            <ul class="card__content-list">
              <li class="card__content-item">
                <span class="card__content-item-label">到店门诊:</span>
                <span class="card__content-item-value">
                  {{ patient.arriveClinic ? patient.arriveClinic : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">一级渠道:</span>
                <span class="card__content-item-value">
                  {{ patient.channelFirst ? patient.channelFirst : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">一级媒介:</span>
                <span class="card__content-item-value">
                  {{ patient.mediumFirst ? patient.mediumFirst : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">首次建档人:</span>
                <span class="card__content-item-value">
                  {{ patient.filingPerson ? patient.filingPerson : '/' }}
                </span>
              </li>
            </ul>
            <ul class="card__content-list">
              <li class="card__content-item">
                <span class="card__content-item-label">首次咨询项目:</span>
                <span class="card__content-item-value">
                  {{
                    patient.networkCounselor ? patient.networkCounselor : '/'
                  }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">二级渠道:</span>
                <span class="card__content-item-value">
                  {{ patient.channelSecond ? patient.channelSecond : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">二级媒介:</span>
                <span class="card__content-item-value">
                  {{ patient.mediumSecond ? patient.mediumSecond : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">初诊TC:</span>
                <span class="card__content-item-value">
                  {{ patient.firstTc ? patient.firstTc : '/' }}
                </span>
              </li>
            </ul>
            <ul class="card__content-list">
              <li class="card__content-item">
                <span class="card__content-item-label">三级渠道:</span>
                <span class="card__content-item-value">
                  {{ patient.channelThird ? patient.channelThird : '/' }}
                </span>
              </li>

              <li class="card__content-item">
                <span class="card__content-item-label">三级媒介:</span>
                <span class="card__content-item-value">
                  {{ patient.mediumSecond ? patient.mediumSecond : '/' }}
                </span>
              </li>
              <li class="card__content-item">
                <span class="card__content-item-label">首次到店时间:</span>
                <span class="card__content-item-value">
                  {{
                    patient.firstOnClinicTime ? patient.firstOnClinicTime : '/'
                  }}
                </span>
              </li>
            </ul>
          </div>
        </el-card>
        <el-card class="rCard2" style="min-height: 110px">
          <div class="xian"></div>
          <div class="rbox2">
            <ul class="card__content-list">
              <li class="card__content-item">
                <span
                  class="card__content-item-value"
                  :class="{ noHave: patient.remarks ? false : true }"
                >
                  {{ patient.remarks ? patient.remarks : '目前暂无备注哟~' }}
                </span>
              </li>
            </ul>
          </div>
        </el-card>
      </div>
    </div>
    <div v-hasPermi="['shop:details:edit']" class="footer">
      <el-button
        v-if="market"
        class="footer__button"
        type="primary"
        @click="handleUpdatePatientPanel"
        >编辑</el-button
      >
      <update-patient-panel
        v-model="visible"
        :patient="patient"
        @ok="$emit('change')"
      ></update-patient-panel>
    </div>
  </div>
</template>

<script>
import {
  sexEnum,
  phoneOwnershipEnum,
  maritalStatusEnum,
  haveChildEnum,
  customerStatusEnum,
  temporaryPatientEnum,
  economicAbilityEnum,
  spendingHabitsEnum,
  characterEnum,
  professionalEnum,
  referrerRelationshipEnum,
  entityEnum,
} from '@/utils/enums'
import { UpdatePatientPanel } from '@/views/shop/components'
import { mapGetters } from 'vuex'
import { getPhone } from '@/api/erp/common'

export default {
  name: 'PatientInformationPane',
  components: {
    UpdatePatientPanel,
    AvatarImage: () => import('@/components/yiya/avatarImage'),
  },
  props: {
    patient: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      visible: false,
      showBtn: true,
      market: true,
    }
  },
  computed: {
    ...mapGetters('dict', ['phoneOwnershipOptions']),
    sexEnum() {
      return sexEnum
    },
    phoneOwnershipEnum() {
      return phoneOwnershipEnum
    },
    maritalStatusEnum() {
      return maritalStatusEnum
    },
    haveChildEnum() {
      return haveChildEnum
    },
    customerStatusEnum() {
      return customerStatusEnum
    },
    temporaryPatientEnum() {
      return temporaryPatientEnum
    },
    economicAbilityEnum() {
      return economicAbilityEnum
    },
    spendingHabitsEnum() {
      return spendingHabitsEnum
    },
    characterEnum() {
      return characterEnum
    },
    professionalEnum() {
      return professionalEnum
    },
    referrerRelationshipEnum() {
      return referrerRelationshipEnum
    },
    entityEnum() {
      return entityEnum
    },
  },
  mounted() {
    if (this.$route.path === '/userMessageHandle/userHandle') {
      this.market = false
    }
  },
  methods: {
    handleUpdatePatientPanel() {
      this.visible = true
    },
    async phone(params) {
      const { data } = await getPhone(params)
      return data
    },
    checkPhone() {
      this.$confirm(
        '确认要查看"' + this.patient.name + '"的联系方式吗?',
        '警告',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }
      )
        .then(() => {
          let params = {
            id: this.patient.id,
            type: 1,
          }
          return this.phone(params)
        })
        .then((res) => {
          this.patient.phoneNumber = res.phoneNumber1
          this.patient.phoneNumber2 = res.phoneNumber2
          this.showBtn = false
          this.msgSuccess('成功')
        })
        .catch(function () {
          return
        })
    },
  },
}
</script>

<style lang="scss" scoped>
.footer {
  display: flex;
  justify-content: flex-end;

  .footer__button {
    margin: 10px 20px;
  }
}
.elFromItem >>> .el-form-item__content {
  margin: 0 !important;
}
.card__content-list {
  padding-left: 0;

  .card__content-item {
    margin: 10px;
    padding-left: 0;
    display: flex;

    .card__content-item-label {
      font-size: 16px;
      color: #2d405e;
      font-weight: 700;
      min-width: 86px;
      display: inline-block;
      text-align: right;
    }
    .card__content-item-value {
      font-size: 16px;
      color: #798fb1;
      margin-left: 20px;
    }
  }
}
.msgBox {
  display: flex;
  justify-content: space-between;
  .leftBox {
    height: 100%;
    width: 38%;
    .leftCard {
      min-height: 550px;
      position: relative;
      border-top: 2px solid #0755c2;
      .xian {
        position: absolute;
        left: 0;
        top: 0;
        height: 4px;
        width: 80px;
        background-color: #0755c2;
      }
      .msg {
        display: flex;
        flex-direction: column;
        padding: 0 20px;
        .box1 {
          margin-top: 30px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .avatar {
            display: flex;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            margin-right: 22px;
            img {
              height: 100%;
              width: 100%;
              border-radius: 50%;
              flex-shrink: 0;
            }
          }
        }
        .box2 {
          display: flex;
          justify-content: space-between;
          align-items: center;
          border-top: 2px solid #ccc;
        }
        .box3 {
          display: flex;
          justify-content: space-between;
          align-items: center;
          border-top: 2px solid #ccc;
        }
      }
    }
  }
  .rightBox {
    display: flex;
    flex-direction: column;
    width: 60%;
    .rCard {
      position: relative;
      border-top: 2px solid #0755c2;
      .xian {
        position: absolute;
        left: 0;
        top: 0;
        height: 4px;
        width: 80px;
        background-color: #0755c2;
      }
      .rbox1 {
        display: flex;
        ul {
          width: 50%;
        }
      }
      .rbox2 {
        padding: 0 40px;
        display: flex;
        justify-content: space-between;
      }
    }
    .rCard2 {
      margin-top: 14px;
      position: relative;
      border-top: 2px solid #f76359;
      .xian {
        position: absolute;
        left: 0;
        top: 0;
        height: 4px;
        width: 80px;
        background-color: #f76359;
      }
    }
    .rCard3 {
      margin-top: 14px;
      position: relative;
      border-top: 2px solid #0755c2;
      .xian {
        position: absolute;
        left: 0;
        top: 0;
        height: 4px;
        width: 80px;
        background-color: #0755c2;
      }
    }
  }
}
</style>
